﻿using System.Drawing;
using System.Windows.Media.Imaging;

namespace InteractiveMapApp
{
    /// <summary>
    /// Bunch of general helper/utility methods
    /// </summary>
    class Utility
    {
        /// <summary>
        /// Convert Bitmap so its appropriate to use as ImageSource
        /// </summary>
        /// <param name="image"></param>
        /// <returns></returns>
        public static BitmapImage GetImage(Bitmap image)
        {
            System.Windows.Media.Imaging.BitmapImage bmp = new System.Windows.Media.Imaging.BitmapImage();
            System.IO.MemoryStream mem = new System.IO.MemoryStream();
            image.Save(mem, System.Drawing.Imaging.ImageFormat.Png);
            bmp.BeginInit();
            bmp.StreamSource = mem;
            bmp.EndInit();
            return bmp;
        }
    }
}
